/*************************************************************************
	> File Name: main.cc
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/09/28 16:54
 ************************************************************************/

#include "comm.hpp"
#include "ProdCon.hpp"
#include "RingQueue.hpp"

int main(int argc, char *argv[])
{
    RingQueue<DATA> *rq = new RingQueue<DATA>();
    pthread_t p[PRO_NUM], c[CON_NUM];
    for (int i = 0; i < PRO_NUM; ++i) {
        pthread_create(p + i, nullptr, producer, (void*)rq);
    }
    for (int i = 0; i < CON_NUM; ++i) {
        pthread_create(c + i, nullptr, consumer, (void*)rq);
    }
    for (int i = 0; i < PRO_NUM; ++i) {
        pthread_join(p[i], nullptr);
    }
    for (int i = 0; i < CON_NUM; ++i) {
        pthread_join(c[i], nullptr);
    }
    delete rq;
    return 0;
}


